package com.zhuiyun.educations.api.address.controller;

import com.zhuiyun.educations.api.address.entity.AddressEntity;
import com.zhuiyun.educations.api.address.service.AddressService;
import com.zhuiyun.educations.common.response.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @ClassName AddressController
 * @Description TODO
 * @Author cjl
 * @Date 2023/6/23 11:37
 **/
@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    AddressService addressService;
    /**
    * @Author cjl
    * @Description 通过用户id查询用户收货地址
    * @Date 2023/6/23 14:15
    * @Return com.zhuiyun.educations.common.response.CommonResult
    * @param id
    */
    @GetMapping("/selectAddressById")
    CommonResult selectAddressById (Integer id){
        return addressService.selectAddressById(id);
    }
    /**
     * @Author cjl
     * @Description 修改用户绑定的地址
     * @Date 2023/6/26 8:54
     * @Return com.zhuiyun.educations.common.response.CommonResult
     * @param addressEntity
     */
    @PutMapping("/updateAddress")
    CommonResult updateAddress(AddressEntity addressEntity){
        return  addressService.updateAddress(addressEntity);
    }
    /**
     * @Author cjl
     * @Description 绑定用户地址
     * @Date 2023/6/26 8:54
     * @Return com.zhuiyun.educations.common.response.CommonResult
     * @param addressEntity
     */
    @PutMapping("/addAddress")
    CommonResult addAddress(AddressEntity addressEntity){
        return  addressService.addAddress(addressEntity);
    }

}
